package router

import (
	"github.com/gin-contrib/zap"
	"github.com/gin-gonic/gin"
	"go-admin/src/module"
	"html/template"
	"time"
)

func Routers() *gin.Engine {
	var Router = gin.New()
	logger:=module.GetLogger()
	Router.Use(ginzap.Ginzap(logger,time.RFC3339,true))
	Router.Use(ginzap.RecoveryWithZap(logger,true))

	Router.Static("/static/asset", "./static/asset")
	//Router.StaticFS("/more_static", http.Dir("my_file_system"))
	//Router.StaticFile("/favicon.ico", "./resources/favicon.ico")



	html := template.Must(template.ParseGlob("./static/html/**/*"))

	Router.SetHTMLTemplate(html)

   // Router.Use(gin.Recovery())
	AdminGroup := Router.Group("admin")
	AdminUserRouter(AdminGroup)

	ApiGroup := Router.Group("v1")
	InitUserRouter(ApiGroup) // 注册用户路由




	return Router
	//app := iris.New()
	//validat := validator.New()
	//
	//
	//app.Validator = validat
	//
	//AdminGroup := app.Party("/admin")
	//AdminUserRouter(AdminGroup)
	//
	//ApiGroup := app.Party("/v1")
	//InitUserRouter(ApiGroup) // 注册用户路由
	//
	//
	//app.HandleDir("/static/asset", iris.Dir("./static/asset"))
	//
	//tmpl := iris.HTML("./static/html", ".html")
	//tmpl.Delims("{{[","]}}")
	//tmpl.Reload(true)
	//app.RegisterView(tmpl)
	//
	//return app
}
